Skip to content

docs(zarr-metadata): say that to_json returns arrays as tuples - #441

Open
d-v-b wants to merge 2 commits into
mainfrom
docs/zarr-metadata-to-json-tuples
Open

d-v-b wants to merge 2 commits into
mainfrom
docs/zarr-metadata-to-json-tuples

Conversation

@d-v-b

@d-v-b d-v-b commented Nov 6, 2026

Copy link
Copy Markdown
Owner

🤖 AI text below 🤖

The to_json docstrings and the guide now say what to_json returns: a copy in which each JSON array is a tuple, as the package's JSON types spell an array, so it does not compare equal to what json.loads returns. They point to comparing models instead. The guide had said to_json returns plain containers.

Why

A downstream user (refkv) reported that ZarrV3ArrayMetadata.from_json(doc).to_json() == doc is false and that isinstance(x, list) checks on the result fail. Tuples are deliberate: every JSON TypedDict in the package declares arrays as tuple[...] (covariant, unlike list), and to_json returns what its type declares, as pydantic's model_dump() keeps tuple fields as tuples. What was wrong is the docs: docs/index.md said to_json returns plain containers, while a later section said it returns tuples, and the docstrings only said "refined".

Changes

  • The six model to_json docstrings (v3 array, group, consolidated metadata; v2 array, group, .zmetadata) say each array is a tuple and each object a new dict, and point to from_json(document) == model for comparison.
  • docs/index.md replaces "to_json returns plain containers" with the same explanation, noting that model comparison also treats an omitted default as equal to the default written out.

just check passed locally.

🤖 Generated with Claude Code

d-v-b and others added 2 commits November 6, 2026 14:13
The guide said `to_json` returns plain containers, while another section
said it returns tuples. Each model's `to_json` docstring now says that
every JSON array is a tuple, as the package's JSON types spell one, so
the result does not compare equal to `json.loads` output, and points to
comparing models instead. Prompted by refkv's report.

Assisted-by: ClaudeCode:claude-opus-5-5
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Assisted-by: ClaudeCode:claude-opus-5-5
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant